﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using TCM.ModelDb;
using TCM.DbContextt;
using TCM.Models;

namespace TCM.Forms
{
    public partial class MainForm : Form
    {

        private BaseContext baseContext;
        public MainForm()
        {
            InitializeComponent();
            LoginForm login = new LoginForm();
            login.ShowDialog();
          
            baseContext = new BaseContext();
            RefreshData();
            
        }

        private void button1_Click(object sender, EventArgs e)
        {
            new CasesList().Show();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            new CategoriesList().Show();
        }

        private void button3_Click(object sender, EventArgs e)
        {
            new RazdelsList().Show();
        }

        private void button4_Click(object sender, EventArgs e)
        {
            new TargetObjectList().Show();
        }

        private void MainForm_Load(object sender, EventArgs e)
        {

        }

        private void groupBox2_Enter(object sender, EventArgs e)
        {

        }

        private void button6_Click(object sender, EventArgs e)
        {
            new TestPlanManager().Show();
        }

        private void MainForm_Enter(object sender, EventArgs e)
        {
            RefreshData();
        }


        private void RefreshData()
        {
            lb1.Text = baseContext.Razdels.Count().ToString();
            lb2.Text = baseContext.TargetObjects.Count().ToString();
            lb3.Text = baseContext.Categories.Count().ToString();
            lb4.Text = baseContext.Cases.Count().ToString();
            Loginlabel.Text = Program.UserLogin;
        }

        private void button5_Click(object sender, EventArgs e)
        {
            new AddCasesToPlans().Show();
        }

        private void button7_Click(object sender, EventArgs e)
        {
            new WorkWithPlans().Show();
        }

        private void CreateUser_Click(object sender, EventArgs e)
        {
            new UserManager().Show();
        }

        private void button8_Click(object sender, EventArgs e)
        {
            new AddPlanToUser().Show();
        }


    }
}
